package com.mvp.base;

import android.app.Application;
import android.arch.lifecycle.AndroidViewModel;
import android.support.annotation.NonNull;

import com.mvp.dagger.modules.NetworkModule;

import io.reactivex.disposables.CompositeDisposable;
import retrofit2.Retrofit;

/**
 * Created by zhangyuncai on 2019/5/30.
 */
public class BaseViewModel extends AndroidViewModel {
    protected LoadMvpView loadMvpView;
    protected CompositeDisposable composite;
    protected Retrofit retrofit;

    public void setLoadMvpView(LoadMvpView loadMvpView) {
        this.loadMvpView = loadMvpView;
    }

    public BaseViewModel(@NonNull Application application) {
        super(application);
        this.composite = new CompositeDisposable();
        retrofit = NetworkModule.getRetrofit();
    }

    @Override
    protected void onCleared() {
        super.onCleared();
        if (composite != null && !composite.isDisposed()) {
            composite.dispose();
        }
    }
}
